<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<script type="text/javascript">
			/**
			 * 根据年月判断多少天
			 * @param {Object} year
			 * @param {Object} month
			 * @return {Number}
			 */
			function getDayByYearMonth(year, month) {
				var day = 0;
				if(month == 2) {
					if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
						return 29;
					} else {
						return 28;
					}

				} else if(month == 4 || month == 6 || month == 9 || month == 11) {
					return 30;
				} else {
					return 31;
				}
				return day;
			}
			/***
			 * 1900年到YEAR的天数差	 
			 * @param {Object} year
			 */
			function getSumByYear(year) {
				var sumday = 0;
				for(var i = 1900; i < year; i++) {
					//					var isrun = ;
					//					if(isrun) {
					//						sumday += 366;
					//					} else {
					//						sumday += 365;
					//					}
					sumday += Isrunbyyear(i) ? 366 : 365;
				}
				return sumday;
			}
			/***
			 * 根据年份判断是否是闰年
			 * @param {Object} year
			 */
			function Isrunbyyear(year) {
				if(month == 2) {
					if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
						return true;
					} else {
						return false;
					}
				}
			}
			/***
			 * 从1月份到month的1号天数差
			 * @param {Number} year  当前年
			 * @param {Number} month  当前月
			 * @return{Number}
				
			 */
			function getSumByMonth(year, month) {
				var sumday = 0;
				for(var i = i; i < month; i++) {
					sumday += getDayByYearMonth(year, i)

				}

				return sumday;
			}
			/***
			 * 某年某月一号星期几
			 * @param {Object} year
			 * @param {Object} month
			 * @return{Number}
			 */
			function getweekByYearMonth(year, month) {
				var sumday = getSumByYear(year);
				sumday += getSumByMonth(year, month);

				return(sumday + 1) % 7;
			}

			function wannianli(year, month, week, day) {
				var day=getDayByYearMonth(year, month)
				document.write("<table>")
				document.write("<tr><th colspan='7'>" + nian + "年" + yue + "月共" + day + "天<br />" + "</th></tr>")
				document.write("<tr><th >日</th><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th></tr>")
                
				document.write("</table>")
			}

							var year = 2016;
							var month = 5;
							var day =getDayByYearMonth(year, month)
//							var week = getweekByYearMonth(year, month);
							var pgonte=wannianli(year, month, week, day);
		</script>

	</body>

</html>